// see http://vuejs-templates.github.io/webpack for documentation.
var path = require('path')
var isProd = process.env.NODE_ENV === 'production'
module.exports = {
  build: {
    env: require('./prod.env'),
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    productionSourceMap: false,
    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css']
  },
  dev: {
    env: require('./dev.env'),
    port: 8080,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {
      '^/apiv1/**': 'http://192.168.3.67:28080'
    },
    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: true
  },
  webpack: {
    entry: {
      admin: './src/views/admin/index.js',
      isCreateCompany: './src/views/is-create-company/index.js',
      createCompany: './src/views/create-company/index.js',
      products: './src/views/products/index.js',
      applyCompany: './src/views/apply-company/index.js',
      companys: './src/views/companys/index.js',
      invite: './src/views/invite/index.js'
    },
    template: [{
      filename: isProd ? path.resolve(__dirname, '../dist/admin/index.html') : 'admin/index.html',
      template: './src/views/admin/index.html',
      inject: true,
      xhtml: true,
      chunks: ['manifest', 'vendor', 'admin'],
      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      chunksSortMode: 'dependency'
    }, {
      filename: isProd ? path.resolve(__dirname, '../dist/is-create-company.html') : 'is-create-company.html',
      template: './src/views/is-create-company/index.html',
      inject: true,
      xhtml: true,
      chunks: ['manifest', 'vendor', 'isCreateCompany'],
      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      chunksSortMode: 'dependency'
    }, {
      filename: isProd ? path.resolve(__dirname, '../dist/create-company.html') : 'create-company.html',
      template: './src/views/create-company/index.html',
      inject: true,
      xhtml: true,
      chunks: ['manifest', 'vendor', 'createCompany'],
      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      chunksSortMode: 'dependency'
    }, {
      filename: isProd ? path.resolve(__dirname, '../dist/products.html') : 'products.html',
      template: './src/views/products/index.html',
      inject: true,
      xhtml: true,
      chunks: ['manifest', 'vendor', 'products'],
      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      chunksSortMode: 'dependency'
    }, {
      filename: isProd ? path.resolve(__dirname, '../dist/invite-join.html') : 'invite-join.html',
      template: './src/views/invite/index.html',
      inject: true,
      xhtml: true,
      chunks: ['manifest', 'vendor', 'invite'],
      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      chunksSortMode: 'dependency'
    }, {
      filename: isProd ? path.resolve(__dirname, '../dist/apply-company.html') : 'apply-company.html',
      template: './src/views/apply-company/index.html',
      inject: true,
      xhtml: true,
      chunks: ['manifest', 'vendor', 'applyCompany'],
      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      chunksSortMode: 'dependency'
    }, {
      filename: isProd ? path.resolve(__dirname, '../dist/companys.html') : 'companys.html',
      template: './src/views/companys/index.html',
      inject: true,
      xhtml: true,
      chunks: ['manifest', 'vendor', 'companys'],
      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
      chunksSortMode: 'dependency'
    }]
  }
}
